<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/11
 * Time: 11:36
 */
include "config.php";
include "status.php";

if($_SERVER["REQUEST_METHOD"]!="POST"){
    print_r(json_encode(Status::$login_nget));
    return;
}
if(isset($_REQUEST["uemail"])){
    if(isset($_REQUEST["upwd"])){
        $UEMAIL=$_REQUEST["uemail"];
        $UPWD=$_REQUEST["upwd"];
        $sql="SELECT `u_id`,`u_email`,`u_name` FROM userinfo WHERE u_email=? AND u_pwd=?";
        $stmt=$conn->prepare($sql);
        $stmt->bind_param("ss",$UEMAIL,$UPWD);
        $stmt->execute();
        $resultArr=$stmt->get_result();
        if($resultArr->num_rows>=1){
            Status::$login_success["data"]=$resultArr->fetch_assoc();
            print_r(json_encode(Status::$login_success));
        }
        else{
            print_r(json_encode(Status::$login_error));
        }
    }
}
else if(isset($_REQUEST["uname"])){
    if(isset($_REQUEST["upwd"])){
        $UNAME=$_REQUEST["uname"];
        $UPWD=$_REQUEST["upwd"];
        $sql="SELECT `u_id`,`u_email`,`u_name`  FROM userinfo WHERE u_name=? AND u_pwd=?";
        $stmt=$conn->prepare($sql);
        $stmt->bind_param("ss",$UNAME,$UPWD);
        $stmt->execute();
        $resultArr=$stmt->get_result();
        if($resultArr->num_rows>=1){
            Status::$login_success["data"]=$resultArr->fetch_assoc();
            print_r(json_encode(Status::$login_success));
        }
        else{
            print_r(json_encode(Status::$login_error));
        }
    }
}
else{
    print_r(json_encode(Status::$login_Null));
}


